package com.mall.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mall.demo.entity.Gwc;
import com.mall.demo.entity.User;
import com.mall.demo.mapper.GwcMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/GWC")
public class GwcController {


    @Autowired
    private GwcMapper gwcMapper;

    @PostMapping("/addOne")
    @CrossOrigin
    public void addGWC(@RequestBody Gwc gwc){
        int insert = gwcMapper.insert(gwc);
        System.out.println(insert);
    }


    @GetMapping("/getuid")
    @CrossOrigin
    public List<Gwc> getOne(String uid){
        QueryWrapper<Gwc> wrapper = new QueryWrapper<>();
        wrapper.eq("uid" , uid);
        List<Gwc> gwc =  gwcMapper.selectList(wrapper);
        return gwc;
    }

    @DeleteMapping("/del")
    @CrossOrigin
    public void delByUid(String uid){
        HashMap<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        int delete = gwcMapper.deleteByMap(map);
    }

    @DeleteMapping("/delbyid")
    @CrossOrigin
    public void delByid(String id){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        int delete = gwcMapper.deleteByMap(map);
    }



}
